<template>
    <div id="memos" class="container">
        <MemoItem v-for="(item, index) in filterMemo()" :key="index" :memo="item">
            {{ item.title }} -
        </MemoItem>
    </div>
</template>
<script lang="ts">
// 1.导入 vue
import ItemData from '@/model/ItemData'
import MemoItem from './MemoItem.vue'
import {Component, Vue} from 'vue-property-decorator'
@Component({
    components: {
        MemoItem
    }
})
// 2.编写组件类
export default class ItemList extends Vue{
    // a.声明 笔记数组 (方便在 当前 组件中调用)
    memoArr: Array<ItemData> = this.$store.state.aHelper.memoList

    filterMemo() {
        if(this.$store.state.filterCateId === -1) {
            return this.memoArr
        }else{
            return this.memoArr.filter(item => item.categoryId === this.$store.state.filterCateId)
        }
    }
}
</script>